layui.use(['table', 'admin', 'ax', 'func'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var func = layui.func;

    /**
     * 我的签到管理
     */
    var EduCourseSelectionInfo = {
        tableId: "eduCourseSelectionInfoSignTable"
    };

    /**
     * 初始化表格的列
     */
    EduCourseSelectionInfo.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'uniqueKey', hide: true, title: ''},
            {field: 'curriculumId',hide:true, sort: true, title: '课程编号'},
            {field: 'studentId', sort: true, title: '学号'},
            {field: 'studentName', sort: true, title: '学生姓名'},
            {align: 'center', field: 'curriculumLink', sort: true, title: '课程名称'},
            {field: 'teacherId',hide:true, sort: true, title: '教师编号'},
            {field: 'teacherName', sort: true, title: '教师姓名'},
            {field: 'timeForClass', sort: true, title: '上课时间'},
            {field: 'classroom', sort: true, title: '教室'},
            {field: 'signTime', title: '签到时间'},
            {align: 'center', field: 'curriculumIcon', title: '签到状态',templet:function (d) {
                    var e = d.status;
                    if(e==1){
                        e = '<a style="color: #0000ff">已签到</a>';
                        return e;
                    }
                    if(e==2){
                        e = '<a style="color: #0000ff">未签到</a>';
                        return e;
                    }
                    if(e==3){
                        e = '<a style="color: #0000ff">请假</a>';
                        return e;
                    }
                }}
        ]];
    };

    var tableHeigth = $(document).height();
    var lineHeight = $(".layui-form-item").height();
    var tableLine = tableHeigth / (lineHeight + 4);
    var lineNum = parseInt(tableLine) / 5 ;
    lineNum = Math.max((parseInt(lineNum) * 5), 5);
    
    // 渲染表格
    var tableResult = table.render({
        elem: '#' + EduCourseSelectionInfo.tableId,
        url: Feng.ctxPath + '/eduCourseSelectionInfo/mysign',
        page: true,
        limit: lineNum,
        limits: [10,15,20,25,30,50,100],
        defaultToolbar:['filter', 'print'],
        toolbar: false,
        even: true,        
        height: "full-98",
        cellMinWidth: 100,
        cols: EduCourseSelectionInfo.initColumn()
    });
});
